home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / go32 / eventque.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-28  |  5.2 KB  |  154 lines

  1. /**
  2.  ** EVENTQUE.H
  3.  **
  4.  **  Copyright (C) 1992, Csaba Biegl
  5.  **    820 Stirrup Dr, Nashville, TN, 37221
  6.  **    csaba@vuse.vanderbilt.edu
  7.  **
  8.  **  This file is distributed under the terms listed in the document
  9.  **  "copying.cb", available from the author at the address above.
  10.  **  A copy of "copying.cb" should accompany this file; if not, a copy
  11.  **  should be available from where this file was obtained.  This file
  12.  **  may not be distributed without a verbatim copy of "copying.cb".
  13.  **  You should also have received a copy of the GNU General Public
  14.  **  License along with this program (it is in the file "copying");
  15.  **  if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  16.  **  Cambridge, MA 02139, USA.
  17.  **
  18.  **  This program is distributed in the hope that it will be useful,
  19.  **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.  **  GNU General Public License for more details.
  22.  **/
  23.  
  24. #ifndef _EVENTQUE_H_
  25. #define _EVENTQUE_H_
  26.  
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30.  
  31. /*
  32.  * structures:
  33.  *  BE CAREFUL when hacking!!! -- 16 and 32 bit compilers have to generate
  34.  *  the same alignments
  35.  */
  36. typedef struct {
  37.     unsigned char   evt_type;        /* event type: 0: keyboard, 1: mouse */
  38.     unsigned char   evt_kbstat;        /* keyboard status (ALT, SHIFT, etc..) */
  39.     unsigned char   evt_mask;        /* mouse event mask */
  40.     unsigned char   evt_button;        /* button status */
  41.     unsigned short  evt_xpos;        /* X coord (or keycode if keybd event) */
  42.     unsigned short  evt_ypos;        /* Y coord */
  43.     unsigned long   evt_time;        /* time stamp of event */
  44. #define evt_keycode   evt_xpos        /* reuse this slot for keybd events !! */
  45. #define evt_scancode  evt_ypos        /* store here the BIOS scan code */
  46. } EventRecord;
  47.  
  48. typedef struct {
  49.     unsigned short  evq_maxsize;    /* max size of event queue */
  50.     unsigned short  evq_cursize;    /* number of events in the queue */
  51.     unsigned short  evq_rdptr;        /* next event to read */
  52.     unsigned short  evq_wrptr;        /* next event to be written */
  53.     short        evq_xpos;        /* current X coordinate of mouse */
  54.     short        evq_ypos;        /* current Y coordinate of mouse */
  55.     short        evq_xmin;        /* minimal mouse X coordinate */
  56.     short        evq_ymin;        /* minimal mouse Y coordinate */
  57.     short        evq_xmax;        /* maximal mouse X coordinate */
  58.     short        evq_ymax;        /* maximal mouse Y coordinate */
  59.     short        evq_xspeed;        /* horizontal speed (mickey/coord) */
  60.     short        evq_yspeed;        /* vertical speed (mickey/coord) */
  61.     unsigned short  evq_thresh;        /* fast movement threshold */
  62.     unsigned short  evq_accel;        /* multiplier for fast move */
  63.     unsigned char   evq_drawmouse;  /* interrupt handler has to draw mouse */
  64.     unsigned char   evq_moved;        /* set if mouse moved */
  65.     unsigned char   evq_delchar;    /* character removed from BIOS buffer */
  66.     unsigned char   evq_enable;        /* event generation control flag */
  67.     EventRecord        evq_events[1];  /* event buffer space */
  68. } EventQueue;
  69.  
  70. /*
  71.  * event types
  72.  */
  73. #define EVENT_KEYBD    0
  74. #define EVENT_MOUSE    1
  75. #define EVENT_RAWKEY    2
  76.  
  77. /*
  78.  * MOUSE event flag bits
  79.  * (also defined in "mousex.h" of the graphics library)
  80.  */
  81. #ifndef M_MOTION
  82.  
  83. #define M_MOTION    0x001
  84. #define M_LEFT_DOWN    0x002
  85. #define M_LEFT_UP    0x004
  86. #define M_RIGHT_DOWN    0x008
  87. #define M_RIGHT_UP    0x010
  88. #define M_MIDDLE_DOWN    0x020
  89. #define M_MIDDLE_UP    0x040
  90. #define M_BUTTON_DOWN    (M_LEFT_DOWN | M_MIDDLE_DOWN | M_RIGHT_DOWN)
  91. #define M_BUTTON_UP    (M_LEFT_UP   | M_MIDDLE_UP   | M_RIGHT_UP)
  92. #define M_BUTTON_CHANGE (M_BUTTON_UP | M_BUTTON_DOWN )
  93.  
  94. /*
  95.  * MOUSE button status bits
  96.  */
  97. #define M_LEFT        1
  98. #define M_RIGHT        2
  99. #define M_MIDDLE    4
  100.  
  101. #endif  /* M_MOTION */
  102.  
  103. /*
  104.  * KEYBOARD status word bits
  105.  * (also defined in "mousex.h" of the graphics library)
  106.  */
  107. #ifndef KB_SHIFT
  108.  
  109. #define KB_RIGHTSHIFT    0x01        /* right shift key depressed */
  110. #define KB_LEFTSHIFT    0x02        /* left shift key depressed */
  111. #define KB_CTRL        0x04        /* CTRL depressed */
  112. #define KB_ALT        0x08        /* ALT depressed */
  113. #define KB_SCROLLOCK    0x10        /* SCROLL LOCK active */
  114. #define KB_NUMLOCK    0x20        /* NUM LOCK active */
  115. #define KB_CAPSLOCK    0x40        /* CAPS LOCK active */
  116. #define KB_INSERT    0x80        /* INSERT state active */
  117.  
  118. #define KB_SHIFT    (KB_LEFTSHIFT | KB_RIGHTSHIFT)
  119.  
  120. #define KB_RAW_LEFTCTRL        0x01
  121. #define KB_RAW_LEFTALT        0x02
  122. #define KB_RAW_RIGHTCTRL    0x04
  123. #define KB_RAW_RIGHTALT        0x08
  124. #define KB_RAW_RIGHTSHIFT    0x10
  125. #define KB_RAW_LEFTSHIFT    0x20
  126. #define KB_RAW_CAPSLOCK        0x40
  127. #define KB_RAW_SYSREQ        0x80
  128.  
  129. #define KB_RAW_SHIFT    (KB_RAW_LEFTSHIFT | KB_RAW_RIGHTSHIFT)
  130. #define KB_RAW_CTRL    (KB_RAW_LEFTCTRL | KB_RAW_RIGHTCTRL)
  131. #define KB_RAW_ALT    (KB_RAW_LEFTALT | KB_RAW_RIGHTALT)
  132.  
  133. #endif  /* KB_SHIFT */
  134.  
  135. /*
  136.  * set this bit in 'evq_enable' to generate the corresponding event
  137.  */
  138. #define EVENT_ENABLE(type)    (1 << (type))
  139.  
  140. /*
  141.  * prototypes
  142.  */
  143. EventQueue *EventQueueInit(int qsize,int ms_stksize,void (*msdraw)(void));
  144. void        EventQueueDeInit(void);
  145. int        EventQueueNextEvent(EventQueue *q,EventRecord *e);
  146.  
  147. #ifdef __cplusplus
  148. }
  149. #endif
  150.  
  151. #endif /* whole file */
  152.  
  153.  
  154.